package pl.edu.agh.sius.model;

import java.io.File;

import javax.faces.model.SelectItem;

import pl.edu.agh.sius.controller.InputFileController;

public class TemporaryBenefitRequestBB implements ConcernBB {

	protected final TemporaryBenefitRequest tbr = new TemporaryBenefitRequest();

	public String getAddress() {
		return tbr.getAddress();
	}

	public String getFirstName() {
		return tbr.getFirstName();
	}

	public String getPesel() {
		return tbr.getPesel();
	}

	public String getStatementOfEarningsDocURL() {
		return tbr.getStatementOfEarningsDocURL();
	}

	public String getSurname() {
		return tbr.getSurname();
	}

	public String getTempBenefitPetitionDocURL() {
		return tbr.getTempBenefitPetitionDocURL();
	}

	public void setAddress(String address) {
		tbr.setAddress(address);
	}

	public void setFirstName(String firstName) {
		tbr.setFirstName(firstName);
	}

	public void setPesel(String pesel) {
		tbr.setPesel(pesel);
	}

	public void setStatementOfEarningsDocURL(String statementOfEarningsDocURL) {
		tbr.setStatementOfEarningsDocURL(statementOfEarningsDocURL);
	}

	public void setSurname(String surname) {
		tbr.setSurname(surname);
	}

	public void setTempBenefitPetitionDocURL(String tempBenefitPetitionDocURL) {
		tbr.setTempBenefitPetitionDocURL(tempBenefitPetitionDocURL);
	}

	public static final String STATEMENT_OF_EARNINGS = "Oświadczenie o dochodach",
			TEMPORAL_BENEFIT_PETITION = "Podanie o zasiłek tymczasowy";

	private static String[] formalDocumentNames = new String[] {
			STATEMENT_OF_EARNINGS, TEMPORAL_BENEFIT_PETITION};

	public SelectItem[] getFormalDocumentsNames() {
		SelectItem[] items = new SelectItem[formalDocumentNames.length];
		for (int i = 0; i < formalDocumentNames.length; ++i) {
			items[i] = new SelectItem(formalDocumentNames[i]);
		}
		return items;
	}

	public boolean areAttachementsValid(InputFileController ifc) {
		if (ifc.getFileList().size() != formalDocumentNames.length) {
			return false;
		}
		for (InputFileData ifd1 : ifc.getFileList()) {
			if (ifd1.getFileFormalName() == null) {
				return false;
			}
			for (InputFileData ifd2 : ifc.getFileList()) {
				if (!ifd1.equals(ifd2)) {
					if (ifd1.getFileFormalName().equals(
							ifd2.getFileFormalName())) {
						return false;
					}
				}
			}
		}
		return true;
	}
	
	private File statmentOfEarningsFile, TemporalBenefitPetitionFile;

	public File getStatmentOfEarningsFile() {
		return statmentOfEarningsFile;
	}

	public void setStatmentOfEarningsFile(File statmentOfEarningsFile) {
		this.statmentOfEarningsFile = statmentOfEarningsFile;
	}

	public File getTemporalBenefitPetitionFile() {
		return TemporalBenefitPetitionFile;
	}

	public void setTemporalBenefitPetitionFile(File temporalBenefitPetitionFile) {
		TemporalBenefitPetitionFile = temporalBenefitPetitionFile;
	}

	private boolean agreement = false;

	public boolean isAgreement() {
		return agreement;
	}

	public void setAgreement(boolean agreement) {
		this.agreement = agreement;
	}

}
